#include "libGeoutils/tool/color_rgb.h"
#include <sstream>

#define R_PROP "R"
#define G_PROP "G"
#define B_PROP "B"
#define A_PROP "A"

geo::tool::ColorRGBA::ColorRGBA(ElementType R, ElementType G, ElementType B, ElementType A)
{
	mIntProps[R_PROP] = R;
	mIntProps[G_PROP] = G;
	mIntProps[B_PROP] = B;
	mIntProps[A_PROP] = A;
}

geo::tool::ColorRGBA::~ColorRGBA()
{
}

void geo::tool::ColorRGBA::setRGBA(ElementType R, ElementType G, ElementType B, ElementType A)
{
	setR(R);
	setG(G);
	setB(B);
	setA(A);
}

void geo::tool::ColorRGBA::getRGBA(ElementType& R, ElementType& G, ElementType& B, ElementType& A) const
{
	R = getR();
	G = getG();
	B = getB();
	A = getA();
}

geo::tool::ColorRGBA::operator std::string() const
{
	std::stringstream ss;
	ss << "(" << getR() << ", " << getG() << ", " << getB() << ", " << getA() << ")";
	return ss.str();
}

void geo::tool::ColorRGBA::setR(ElementType R)
{
	mIntProps[R_PROP] = R;
}

geo::tool::ColorRGBA::ElementType geo::tool::ColorRGBA::getR() const
{
	if (mIntProps.count(R_PROP)) {
		return mIntProps.at(R_PROP);
	} return 0;
}

void geo::tool::ColorRGBA::setG(ElementType G)
{
	mIntProps[G_PROP] = G;
}

geo::tool::ColorRGBA::ElementType geo::tool::ColorRGBA::getG() const
{
	if (mIntProps.count(G_PROP)) {
		return mIntProps.at(G_PROP);
	} return 0;
}

void geo::tool::ColorRGBA::setB(ElementType B)
{
	mIntProps[B_PROP] = B;
}

geo::tool::ColorRGBA::ElementType geo::tool::ColorRGBA::getB() const
{
	if (mIntProps.count(B_PROP)) {
		return mIntProps.at(B_PROP);
	} return 0;
}

void geo::tool::ColorRGBA::setA(ElementType A)
{
	mIntProps[A_PROP] = A;
}

geo::tool::ColorRGBA::ElementType geo::tool::ColorRGBA::getA() const
{
	if (mIntProps.count(A_PROP)) {
		return mIntProps.at(A_PROP);
	} return 0;
}
